<% form_tag :controller => 'rental', :action => 'list_rentals', :method => 'get' do %>
		<%= text_field_tag :search, params[:search], :id => 'search_field' %>
		<%= submit_tag "Search", :name => nil %>
		<%= link_to_function "Clear", "$('search_field').clear()" %>
<% end %>
<table id="rental_table" class="tablesorter">
<thead>
    <tr>
      <th>
        Date Created
      </th>
      <th>
        Checkout Date
      </th>
      <th>
        Checkin Date
      </th>
      <th>
         Customer
      </th>
      <th>
        Status
      </th>
    </tr>
</thead>
<tbody>
<% if @rentals %>
<% for rental in @rentals %>
  <tr>
    <td>
	  <%= h(rental.date_created) %>
	</td><td>
	  <%= h(rental.checkout_date) %>
	</td><td>
	  <%= h(rental.return_date) %>
	</td><td>
	  <% @customer = Customer.find_by_id(rental.customer_id) %>
	  <%= h(@customer.first_name) %> <%= h(@customer.last_name) %>
	</td><td>
	  <% status = rental.rental_status %>
	  <% if status == 0 %>reserved<%end%>
	  <% if status == 1 %>unpaid (<%= h(rental.paid) %> paid)<%end%>
	  <% if status == 2 %>paid<%end%>
	  <% if status == 3 %>LATE<%end%>
	</td>
	<td style="text-align:center">
	  <%= link_to "Details", {:action => "rental_details", :id => rental} %>
	</td>
</tr>
<% end %>
<% else %>
  <tr>
    <td>no rentals</td>
  </tr>
<% end %>
</tbody>
</table>
<script type="text/javascript">
    $("#rental_table").tablesorter();
</script>
